package com.example.moduletwo.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.example.baselibrary.util.BaseResourceUtil;
import com.example.moduletwo.R;
import com.example.moduletwo.bean.TwoMVPBean;
import com.example.moduletwo.binder.TwoMVPBinder;
import com.example.moduletwo.delegate.ModuleTwoMVPActivityDelegate;
import com.example.moduletwo.server.TwoMVPBeanServer;
import com.example.mvp.activity.BaseMVPActivity;
import com.example.mvp.binder.BaseDataBinder;

/**
 * 处理操作的Activity（操作无延迟、UI刷新有延迟）
 * Created by sun.li on 2018/6/5.
 *
 * @author sun.li
 */

public class ModuleTwoMVPActivityOne extends BaseMVPActivity<ModuleTwoMVPActivityDelegate> implements View.OnClickListener {

    private TwoMVPBean twoMVPBean;

    @Override
    protected void initDate() {

    }

    @Override
    protected void initView(@Nullable Bundle bundle) {

    }

    @Override
    protected void bindEvenListener() {
        viewDelegate.setOnClickListener(this, R.id.bt_amvp, R.id.tv_amvp_text_1, R.id.tv_amvp_text_2, R.id.tv_amvp_close);
    }

    @Override
    protected Class<ModuleTwoMVPActivityDelegate> getDelegateClass() {
        return ModuleTwoMVPActivityDelegate.class;
    }

    @Override
    public BaseDataBinder getDataBinder() {
        return new TwoMVPBinder();
//        return null;
    }

    @Override
    public void onClick(View v) {
        if (BaseResourceUtil.whetherResourceIDSame(v.getId(), R.id.bt_amvp)) {
            twoMVPBean = TwoMVPBeanServer.getInstance().disposeBean(twoMVPBean, "ActivityOne_1");
            notifyModelChanged(twoMVPBean);
        } else if (BaseResourceUtil.whetherResourceIDSame(v.getId(), R.id.tv_amvp_text_1)) {
            twoMVPBean = TwoMVPBeanServer.getInstance().disposeBean(twoMVPBean, "ActivityOne_2");
            notifyModelChanged(twoMVPBean);
        } else if (BaseResourceUtil.whetherResourceIDSame(v.getId(), R.id.tv_amvp_text_2)) {
            twoMVPBean = TwoMVPBeanServer.getInstance().disposeBean(twoMVPBean, "ActivityOne_3");
            notifyModelChanged(twoMVPBean);
        } else if (BaseResourceUtil.whetherResourceIDSame(v.getId(), R.id.tv_amvp_close)) {
            finish();
        }
    }

}
